<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>学生学习互动系统登录页面</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script src="js/jquery-2.1.0.min.js"></script>
    <script type="text/javascript"></script>
    <style>
        html, body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: auto;
        }
        body {
            background: url(images/6.jpg) no-repeat 100% 100%;
            background-size: cover;
        }
    </style>

</head>
<div id="bar" style="background-color: rgba(0, 0, 0, .4);
    color: #eee;
    display: flex;
    width: 100%;
    height: 60px;
    align-items: stretch;
    justify-content: space-between;
    padding-left: 100px;
    padding-right: 100px;">
    <div id="bar-left" style="display: flex;
    align-items: center;
    width: 250px;
    justify-content: space-between;" >
        <div id="logo" style = "width: 50px;height: 50px;border-radius: 50%;overflow:hidden;">
            <img src="images/xufe.jpg" style="height: 50px;">
        </div>
        <div id="name" style="font-size:20px">
            学生学习互动系统
        </div>
    </div>
    <div id="bar-right" style="display: flex;
    align-items: center;
    width: 80px;
    justify-content: space-between;">
        <a href="register.html" style="color: #eee;font-size:15px;text-decoration: none;">注册</a>
    </div>
</div>
<body id="body">
<div class="container" style="width: 400px;margin-top: 110px;border-radius: 16px;background-color: rgba(255,255,255,0.8)">
    <h3 style="text-align: center;">学生登陆</h3>
    <div class="form-group">
        <label for="loginname">用户名：</label>
        <input type="text" name="user" class="form-control" id="loginname" placeholder="请输入用户名"/>
    </div>

    <div class="form-group">
        <label for="password">密码：</label>
        <input type="password" name="password" class="form-control" id="password" placeholder="请输入密码"/>
    </div>

    <hr/>
    <div class="form-group" style="text-align: center;">
        <input style="width: 200px;height: 40px;border-radius: 16px" id="submit"
               class="btn btn btn-primary" type="button" value="登录" onclick="mysub()">
    </div>

</div>
<script>
    function mysub(){
        //1.非空校验
        var loginname = jQuery("#loginname");
        var password = jQuery("#password");
        if(jQuery.trim(loginname.val())==""){
            alert("请先输入用户名！");
            loginname.focus();
            return false;
        }
        if(jQuery.trim(password.val())==""){
            alert("请先输入密码！");
            password.focus();
            return false;
        }
        jQuery.ajax({
            url:"login",
            type:"POST",
            data:{"loginname":loginname.val(),"password":password.val()},
            success:function(result){
                if(result!=null&&result.data==true){
                    alert("恭喜：登录成功！");
                    location.href = "list.html";

                }else{
                    alert("抱歉；用户名或密码错误，请重新输入!");
                }
            }
        });
    }

</script>
</body>
</html>